﻿using System;
using System.Web.Security;
using System.Web.UI.WebControls;
using BLL;

public partial class ViewTest_ViewYourself_ViewPIMTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string str1 = Membership.GetUser().UserName.ToString();
        Label2.Text = str1;    
    }

    protected void BindTest()
    {
        DateTime dt1 = DateTime.Parse(this.TextBox1.Text + " 00:00:00");
        DateTime dt2 = DateTime.Parse(this.TextBox2.Text + " 00:00:00");
        string str1 = Membership.GetUser().UserName.ToString();
        PIMTest test = new PIMTest();
        //ATEUser aTEUser = new ATEUser();
        //ATEUserInfo aTEUserInfo = aTEUser.GetATEUser(str1);
        //if (aTEUserInfo.UserID == str1)
        //{
        GridView2.DataSource = test.GetPIMTestbyUIDDT(str1, dt1, dt2);
        GridView2.DataBind();
        for (int i = 0; i < GridView2.Rows.Count; i++)
        {
            if (GridView2.Rows[i].Cells[10].Text == "Fail")
                GridView2.Rows[i].Cells[10].ForeColor = System.Drawing.Color.Red;
        }
        //}           
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["productSN"] = GridView2.SelectedDataKey["ProductSN"].ToString();
        Session["testTime"] = Convert.ToDateTime(GridView2.SelectedDataKey["TestTime"]);

        Response.Redirect("~/ViewTest/ViewYourself/PIMTestItemViewbySNDT.aspx");
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView2.PageIndex = e.NewPageIndex;
        BindTest();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        BindTest();
    }
}
